var app = getApp();
Page({
    data:{
        page : {
            isend : false,
            doing : false,
            doo : 'redbag',
            pdata : {
                op : 'list',
                page : 1,
                status : 0,
            },
            waitf : 0,
            nodataf : 0,
        },
        datalist : [],
		siteroot : app.siteInfo.siteroot.replace('app/index.php', ''),uniacid: app.siteInfo.uniacid,
    },
    onLoad:function(options){
        var self = this;
        
		var shopid = options.shopid ? options.shopid : 0;
        var zfid = options.zfid ? options.zfid : '';
        self.setData({
            'page.pdata.status' : options.status ? options.status : 0,
            'page.pdata.zfid' : zfid,
        });

        app.com.getLocation(self,function(loc){
            self.setData({
                'page.pdata.lng' : loc.longitude,
                'page.pdata.lat' : loc.latitude,
            });
            app.com.auth(function(user){
                app.com.getPage(self,self.data.page,20,function(res){
                    var data = res.data.data;
                    self.setData({
                       datalist : data.list,
                       Pagetheme : res.data.data.params.style,
                       sharedata : res.data.data.sharedata,
                    },function(){
                        self.setData({
                            inited : true,
                        });
                    });

                    wx.setNavigationBarTitle({
                      title:  res.data.data.params.title ? res.data.data.params.title : '红包',
                    });

                },false,function(res){
                    app.com.alert(res.data.message);
                });
				app.com.setBar(app,self,shopid);
            });
        })
       
    },
    onReachBottom : function(){
        var self = this;

        app.com.getPage(self,self.data.page,0,function(res){
            self.setData({
                datalist : self.data.datalist.concat(res.data.data.list)
            });
        });
    },
    onShareAppMessage : function(){
        var self = this;
        return {
            title: self.data.sharedata.title,
            path: self.data.sharedata.path,
            imageUrl : self.data.sharedata.img,
        }
    },
    location : function( e ){
        app.com.location( e );
    },
    otherapp : function( e ){
        app.com.otherapp( e );
    },
    navigateto : function( e ){
        app.com.navigateto( e );
    },
    redirectto : function( e ){
        app.com.redirectto( e );
    },    
    callphone : function(e){
        app.com.callphone( e );
    },
    toweburl : function(e){
        app.com.toweburl( e );
    },
    showimages : function( e ){
        app.com.showimages( e );
    },
    footNavigate(e){
        var url = e.currentTarget.dataset.url;
        wx.switchTab({
          url: url
        })
    },

})